<?php

/**
 * export actions.
 *
 * @package    travide
 * @subpackage export
 * @author     Travide Project Group
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class exportActions extends sfActions {
    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request) {
        $this->forward('default', 'module');
    }

    public function executeExportRIFCS(sfWebRequest $request) {
        $this->setLayout(false);
        $response = $this->getResponse();
        $response->setContentType('text/xml');
        $response->addCacheControlHttpHeader('no-cache');
        $exporter = new ExportGeneratorRIFCS();
        $exporter->setRegistryObjectGroup('ansto.gov.au');
        $exporter->setDefaultOriginatingSource('irms.ansto.gov.au');
        $exporter->setKeyPrefix('irms.ansto.gov.au:');
        $exporter->setRifcsTypeMappingListFromDoctrine(Doctrine::getTable('RifCollTypeMapping')->findAll());
        $exporter->setUrlLocationPattern('http://irms.ansto.gov.au/collecton/{uin}');

        $collectionList = Doctrine::getTable('CollectionItem')->getCollectionsByTagNameQuery('rifcsexport')->execute();
        return $this->renderText($exporter->generateExportFromCollections($collectionList)->saveXML());

    }

    public function executeExportTravide(sfWebRequest $request) {
        $this->setLayout(false);
        $response = $this->getResponse();
        $response->setContentType('text/xml');
        $response->addCacheControlHttpHeader('no-cache');
        $exporter = new ExportGeneratorTravide();

        $collectionList = Doctrine::getTable('CollectionItem')->getCollectionsByTagNamesQuery(array('business','public-approved'))->execute();
        return $this->renderText($exporter->generateExportFromCollections($collectionList)->saveXML());

    }
}
